package com.xt.tea.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xt.tea.constant.ApiConstant;
import com.xt.tea.entity.domain.Desk;
import com.xt.tea.entity.vo.Condition;
import com.xt.tea.service.DeskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.xt.tea.entity.bo.RequestResult;

import java.util.List;


@Api("位置相关")
@RestController
@RequestMapping(ApiConstant.API_V1+"desk")
@AllArgsConstructor
public class DeskController {
    
    private final DeskService deskService;
    
    @ApiOperation("分页获取位置")
    @PostMapping("/getDesk")
    public RequestResult<IPage<Desk>> getDesk(@RequestBody Condition<Desk> condition){
        return RequestResult.success(deskService.getDesk(condition));
    }

    @ApiOperation("获取所有位置")
    @GetMapping("/getAllDesk")
    public RequestResult<List<Desk>> getAllDesk(){
        return RequestResult.success(deskService.getAllDesk());
    }

    @ApiOperation("新增位置")
    @PostMapping("/addDesk")
    public RequestResult<Integer> addDesk(@RequestBody Desk deskVo){
        return RequestResult.success(deskService.addDesk(deskVo));
    }
    //修改
    @ApiOperation("更新位置")
    @PutMapping("/updateDesk")
    public RequestResult<Desk> updateDesk(@RequestBody Desk deskVo){
        return RequestResult.success(deskService.updateDesk(deskVo));
    }
    //停用
    @ApiOperation("起停用位置")
    @GetMapping("/updateDeskStatus")
    public RequestResult<Desk> updateDeskStatus(Integer id){
        return RequestResult.success(deskService.updateDeskStatus(id));
    }
    //删除
    @ApiOperation("删除位置")
    @GetMapping ("/deleteDesk")
    public RequestResult<Integer> deleteDesk(Integer id){
        return RequestResult.success(deskService.deleteDesk(id));
    }
}
